<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 * 
 * @desc {cosmo_ajax_init [context="<actual_page>"]} 
 * 		Initiate ajax object manager for the current
 */
 
function smarty_function_cosmo_ajax_init($params, $content, &$smarty){
	// check parameters
	if(!isset($params['page'])) 
		return '';
	
	$loader = Loader::getInstance() ;
	$ajax =& $loader->object('ajax') ;
	$core =& $loader->object('core') ;
	unset($loader) ; // free memory
	$ajax->setContext($param['page']) ;
	return (false === ($js = $ajax->initContext($core->controller))) ? '' : $js ;	
}

?>